<template>
  <div>
    姓名:<input v-model="username" type="text" /> 年龄:
    <input v-model="userage" type="text" />
    <button @click="addlist">添加</button>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  data() {
    username: "";
    userage: "";
  },
  methods: {
    ...mapActions(["addUser"]),
    addlist() {
      const obj = {
        username: this.username,
        userage: this.userage,
      };
      this.addUser(obj);
    },
  },
};
</script>

<style></style>
